package com.controller;

import com.alibaba.fastjson.JSON;
import com.entity.Student;
import com.service.ItestService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by b5m on 2017/11/7.
 */

@Controller
@RequestMapping("/Mav")
public class ModelAndViewController {

    Logger logger = Logger.getLogger(this.getClass());

    @Autowired
    private ItestService itestService;


    /**
     * spring中关于对数据请求的接口
     */
    @RequestMapping(value = "/get", produces = "application/json")
    public
    @ResponseBody
    Map<String, Object> get(@RequestBody String jsonData) {
        logger.info("开始进入get");
        logger.info("参数" + jsonData);
        Map<String, Object> res = new HashMap<String, Object>();
        Student student = itestService.selectOne();
        logger.info("返回" + JSON.toJSONString(student));
        res.put("name", student);
        return res;
    }

}
